/**
 * @Author：ming
 * @Date：2023/10/29 9:35 PM
 * @Filename：Hot240
 */

/**
 * @author ming
 */
public class Hot240 {

    public boolean searchMatrix(int[][] matrix, int target) {
        int row = matrix.length;
        int col = matrix[0].length;
        boolean flag = false;
        int i = 0;
        int j = col-1;
        while (i<row&&j>=0){
            if(matrix[i][j]==target){
                flag = true;
                break;
            }else if(matrix[i][j]<target){
                i++;
            }else {
                j--;
            }
        }

        return flag;
    }
}
